function setRem() {
  const scale = document.documentElement.clientWidth / 1920;
  document.documentElement.style.fontSize = 11.4 * scale + "px";
}

export const initRem = () => {
  // 调用一次，初始化rem
  setRem();
  const i = "orientationchange" in window ? "orientationchange" : "resize";

  // 改变窗口大小时重新设置 rem,用节流防止改变窗口大小时卡死
  let timer = undefined;
  window.addEventListener(i, function () {
    if (timer) {
      clearTimeout(timer);
    }
    timer = window.setTimeout(() => {
      setRem();

      clearTimeout(timer);
    }, 200);
  });
};

initRem();
